package com.gdk.ksoft.data.entry.tables;

import android.os.Parcel;
import android.os.Parcelable;

import com.lidroid.xutils.db.annotation.Column;
import com.lidroid.xutils.db.annotation.Id;
import com.lidroid.xutils.db.annotation.NotNull;
import com.lidroid.xutils.db.annotation.Table;
import com.lidroid.xutils.db.annotation.Transient;
import com.lidroid.xutils.db.annotation.Unique;

/**
 * Created by Mrper on 2014/11/26.
 * 客户欠款表
 */
@Table(name="kehu_qiankuan")
public class CustomerDebtTable extends BaseTable implements Parcelable{

    /**
     * 欠款数据本地ID
     */
    @Unique
    @NotNull
    @Id(column="cid")
    public int cid;

    /**
     * 欠款数据ID值
     */
    @NotNull
    @Column(column="id")
    public int id;

    /**
     * 客户ID
     */
    @NotNull
    @Column(column="kh_id")
    public int kh_id;

    /**
     * 送货地址ID
     */
    @NotNull
    @Column(column="shdz_id")
    public int shdz_id;

    /**
     * 单据号
     */
 //   @NotNull
    @Column(column="djh")
    public String djh;

    /**
     * 销售金额
     */
    @NotNull
    @Column(column="xsje",defaultValue = "0")
    public float xsje;

    /**
     * 抽单金额
     */
    @NotNull
    @Column(column="cdje",defaultValue = "0")
    public float cdje;

    /**
     * 未收金额
     */
    @NotNull
    @Column(column="wsje",defaultValue = "0")
    public float wsje;

    /**
     * 录入时间
     */
//    @NotNull
    @Column(column="lrsj")
    public String lrsj;


    /**
     * 本次收费金额，外部字段
     */
    @Transient
    public float payableMoney = 0;

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeInt(cid);
        dest.writeInt(id);
        dest.writeInt(kh_id);
        dest.writeInt(shdz_id);
        dest.writeString(djh);
        dest.writeFloat(xsje);
        dest.writeFloat(cdje);
        dest.writeFloat(wsje);
        dest.writeString(lrsj);
        dest.writeFloat(payableMoney);
    }

    public static final Creator<CustomerDebtTable> CREATOR = new Creator<CustomerDebtTable>() {
        @Override
        public CustomerDebtTable createFromParcel(Parcel source) {
            CustomerDebtTable item = new CustomerDebtTable();
            item.cid = source.readInt();
            item.id = source.readInt();
            item.kh_id = source.readInt();
            item.shdz_id = source.readInt();
            item.djh = source.readString();
            item.xsje = source.readFloat();
            item.cdje = source.readFloat();
            item.wsje = source.readFloat();
            item.lrsj = source.readString();
            item.payableMoney = source.readFloat();
            return item;
        }

        @Override
        public CustomerDebtTable[] newArray(int size) {
            return new CustomerDebtTable[size];
        }
    };
}
